package cn.itsource.basic.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class AjaxResult {

    //状态码
    private String code;
    //返回消息
    private String message;
    //返回状态
    private Boolean success;
    //返回数据
    private Object data;

    /**
     * 返回操作成功的信息
     */
    public static AjaxResult creatSuccess(){
        return new AjaxResult("0000","操作成功",true,null);
    }

    /**
     * 返回操作成功的信息
     */
    public static AjaxResult creatSuccess(Object obj){
        return new AjaxResult("0000","操作成功",true,obj);
    }

    /**
     * 返回操作失败的信息
     */
    public static AjaxResult creatError(String msg){
        return new AjaxResult("1001",msg,false,null);
    }

    /**
     * 返回操作失败的信息
     */
    public static AjaxResult creatError(String code ,String msg){
        return new AjaxResult(code,msg,false,null);
    }


}
